<?php

//Magic!
require('../Magic/magic.php');
$userSys = new UserSystem();

if($_GET['c']=='save'){

$you = $userSys->getCurrentUser();

$you->set('email',$_POST['email']);
$you->set('dob',$_POST['dob']);
$you->set('title',$_POST['title']);
$you->set('avatar',$_POST['avatar']);
$you->set('description',$_POST['description']);
$you->set('avatar',$_POST['avatar']);
$you->set('signature',$_POST['signature']);

$p = $you->write();

header("location: index.php?profile=".$userSys->getAttribute('uid'));

}

$uid		= $userSys->getAttribute('uid');
$username	= $userSys->getAttribute('name');

?>
<div style='background-color:black;padding:10px;margin:0;color:#ffffff;font-weight:bold;'>
<?php
//$userSys->login('bag','pass');
if($userSys->authenticated()){
	echo "Welcome back <a href='index.php?profile=".$uid."'>".$username.'</a> - <a href="edit.php?profile='.$uid.'">Edit profile</a> - <a href="log.php?log=out">logout</a>';
}else{
	echo "<form action='log.php' method='post'><input name='name' type='text'><input name='pass' type='password'><input type='submit' value='Send'></form>";
}

?>
</div>
<?php
	$you = $userSys->getCurrentUser();

		if($you !==null){
	
		echo '<form method="post" action="edit.php?c=save">';

		echo '
		
		email:<br/>
		<input type="text" name="email" value="'.$you->get('email').'" /> 
		<br>dob:<br/>
		<input type="text" name="dob" value="'.$you->get('dob').'" /> 
		<br>title:<br/>
		<input type="text" name="title" value="'.$you->get('title').'" />
		<br>avatar:<br/>
		<input type="text" name="avatar" value="'.$you->get('avatar').'" /> 
		<br>description:<br/>
		<input type="text" name="description" value="'.$you->get('description').'" /> 
		<br>signature:<br/>
		<input type="text" name="signature" value="'.$you->get('signature').'" /> 
		';
		echo'<input type="submit">';

		echo '</form>';
	
	}else{
		echo 'you int logged in';
	}


?>